<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="UTF-8">
    <title>发货单列表</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link rel="icon" th:href="@{/static/console/common/images/favicon.ico}">
    <link rel="stylesheet" type="text/css" th:href="@{/static/css/element/index.css}"/>
    <link rel="stylesheet" type="text/css"
          th:href="@{/static/console/css/production/invoice.css?version=202503261742}"/>
    <link rel="stylesheet" type="text/css"
          th:href="@{/static/console/css/production/component/indent-select.css?version=202503201742}"/>
    <link rel="stylesheet" type="text/css"
          th:href="@{/static/console/css/production/component/whole-tran.css?version=202503201742}"/>
    <link rel="stylesheet" type="text/css"
          th:href="@{/static/console/css/production/component/invoice-detail.css?version=202503201742}"/>
</head>

<body>
<div id="container">
    <el-container>
        <el-header height="50">
            <el-date-picker v-model="tableSearch.startTime"
                            type="datetime"
                            :value-format="tableSearch.dateFormat"
                            placeholder="起始日期" size="mini">
            </el-date-picker>
            <el-date-picker v-model="tableSearch.endTime"
                            type="datetime"
                            :value-format="tableSearch.dateFormat"
                            placeholder="截止日期" size="mini">
            </el-date-picker>
            <el-select v-model="tableSearch.isAdd" placeholder="方量是否累计" clearable size="mini">
                <el-option label="全部" :value="-1"></el-option>
                <el-option label="累计" value="0"></el-option>
                <el-option label="不累计" value="1"></el-option>
            </el-select>
            <el-input v-model="tableSearch.searchVal" placeholder="搜索信息" clearable size="mini"></el-input>
            <el-button type="success" icon="el-icon-search" @click="searchDatas" size="mini">查询</el-button>
            <template th:if="${menuRole.isInsert == 1}">
                <el-button type="primary" icon="el-icon-plus" @click="showAddDialog" size="mini">添加</el-button>
            </template>
        </el-header>
        <el-main>
            <template>
                <el-table :data="tableDatas" border v-loading="tableLoading" max-height="750" highlight-current-row
                          size="mini">
                    <el-table-column label="序号"
                                     show-overflow-tooltip
                                     type="index"
                                     width="50"></el-table-column>
                    <el-table-column prop="code" show-overflow-tooltip
                                     label="发货单编号"
                                     width="180"></el-table-column>
                    <el-table-column show-overflow-tooltip
                                     prop="conName"
                                     label="工程名称"
                                     width="240"></el-table-column>
                    <el-table-column show-overflow-tooltip
                                     prop="site"
                                     label="施工部位"
                                     width="240"></el-table-column>
                    <el-table-column show-overflow-tooltip
                                     prop="strengthName"
                                     label="砼强度"
                                     width="150">
                    </el-table-column>
                    <el-table-column show-overflow-tooltip
                                     prop="tech"
                                     label="特性要求"
                                     width="150">
                    </el-table-column>
                    <el-table-column label="发货类型"
                                     width="120">
                        <template slot-scope="scope">
                            <template v-if="scope.row.invoiceType == 0">
                                <el-tag>{{scope.row.invoiceTypeTxt}}</el-tag>
                            </template>
                            <template v-else-if="scope.row.invoiceType == 1">
                                <el-tag type="warning">{{scope.row.invoiceTypeTxt}}</el-tag>
                            </template>
                            <template v-else="scope.row.invoiceType == 2">
                                <el-tag type="info">{{scope.row.invoiceTypeTxt}}</el-tag>
                            </template>
                        </template>
                    </el-table-column>
                    <el-table-column show-overflow-tooltip
                                     prop="sendStere"
                                     label="发货方量(方)"
                                     width="120">
                    </el-table-column>
                    <el-table-column show-overflow-tooltip
                                     label="累计车次"
                                     width="120">
                        <template slot-scope="scope">
                            <template v-if="scope.row.process != 6">
                                {{scope.row.totalCar}}
                            </template>
                        </template>
                    </el-table-column>
                    <el-table-column show-overflow-tooltip
                                     label="累计方量"
                                     width="120">
                        <template slot-scope="scope">
                            <template v-if="scope.row.process != 6">
                                {{scope.row.totalStere}}
                            </template>
                        </template>
                    </el-table-column>
                    <el-table-column show-overflow-tooltip
                                     prop="proTime"
                                     label="生产时间"
                                     width="180">
                    </el-table-column>

                    <el-table-column show-overflow-tooltip
                                     prop="castModelName"
                                     label="浇筑方式"
                                     width="150">
                    </el-table-column>
                    <el-table-column show-overflow-tooltip
                                     prop="pumpDeviceName"
                                     label="泵送设备"
                                     width="150">
                    </el-table-column>
                    <el-table-column show-overflow-tooltip
                                     prop="distance"
                                     label="运距(KM)"
                                     width="100"></el-table-column>
                    <el-table-column show-overflow-tooltip
                                     prop="carCode"
                                     label="搅拌车"
                                     width="150">
                    </el-table-column>
                    <el-table-column show-overflow-tooltip
                                     prop="driver"
                                     label="司机"
                                     width="150">
                    </el-table-column>
                    <el-table-column label="生产方式" width="120">
                        <template slot-scope="scope">
                            <template v-if="scope.row.createType == 1">
                                <el-tag type="success">{{scope.row.createTypeTxt}}</el-tag>
                            </template>
                            <template v-else-if="scope.row.createType == 2">
                                <el-tag type="warning">{{scope.row.createTypeTxt}}</el-tag>
                            </template>
                            <template v-else>
                                <el-tag>{{scope.row.createTypeTxt}}</el-tag>
                            </template>
                        </template>
                    </el-table-column>
                    <el-table-column label="生产线"
                                     prop="mixName"
                                     width="80"></el-table-column>
                    <el-table-column label="是否累计" fixed="right" width="80">
                        <template slot-scope="scope">
                            <template v-if="scope.row.isAdd == 1">
                                <el-tag type="danger" size="mini">{{scope.row.isAddTxt}}</el-tag>
                            </template>
                            <template v-else>
                                {{scope.row.isAddTxt}}
                            </template>
                        </template>
                    </el-table-column>
                    <el-table-column fixed="right" label="状态" width="80">
                        <template slot-scope="scope">
                            <template v-if="scope.row.process == 6">
                                <el-tag type="danger" size="mini"
                                >{{scope.row.processTxt}}
                                </el-tag>
                            </template>
                            <template v-else>
                                {{scope.row.processTxt}}
                            </template>
                        </template>
                    </el-table-column>
                    <el-table-column fixed="right"
                                     label="操作"
                                     width="300">
                        <template scope="scope">
                            <el-button-group>
                                <el-tooltip class="item" effect="dark" content="点击查看定位" placement="top">
                                    <el-button icon="el-icon-position" size="mini" type="primary" circle></el-button>
                                </el-tooltip>
                                <el-tooltip content="查看发货单详情" placement="top">
                                    <el-button icon="el-icon-view" size="mini" type="info" circle
                                               @click="showInvDetail(scope.row.id)"></el-button>
                                </el-tooltip>
                                <!--  发货单消耗 -->
                                <el-tooltip content="查看发货单消耗" placement="top">
                                    <el-button icon="el-icon-coin" size="mini" type="success" circle
                                               @click="showExpendDialog(scope.row)"></el-button>
                                </el-tooltip>
                                <el-button th:if="${isAdmin == 1}" icon="el-icon-refresh" size="mini" type="success"
                                           circle @click="resetExpend(scope.row)">
                                    <!-- 重置发货单的消耗 -->
                                </el-button>
                                <el-button icon="el-icon-printer" size="mini" type="info" circle
                                           @click="printInvoice(scope.row.id)"></el-button>
                            </el-button-group>
                            <template v-if="scope.row.process != 6">
                                <template th:if="${menuRole.isUpdate == 1}">
                                    <el-button-group>
                                        <el-tooltip class="item" effect="dark" content="点击修改发货单信息" placement="top">
                                            <el-button icon="el-icon-edit" size="mini" type="primary" circle
                                                       @click="showEditDialog(scope.row)"></el-button>
                                        </el-tooltip>
                                        <el-dropdown @command="((item) => handleTran(item,scope.row))">
                                            <el-button icon="el-icon-d-arrow-right" size="mini" type="primary"
                                                       circle></el-button>
                                            <el-dropdown-menu slot="dropdown">
                                                <el-dropdown-item command="0">整车转出</el-dropdown-item>
                                                <el-dropdown-item command="1">分车转料</el-dropdown-item>
                                            </el-dropdown-menu>
                                        </el-dropdown>
                                    </el-button-group>
                                </template>
                                <template th:if="${menuRole.isDelete == 1}">
                                    <el-tooltip class="item" effect="dark" content="点击整车作废" placement="top">
                                        <el-popconfirm title="确定作废该发货单吗？" @confirm="scrapInvoice(scope.row.id)">
                                            <el-button icon="el-icon-delete" size="mini" type="danger" slot="reference"
                                                       circle></el-button>
                                        </el-popconfirm>
                                    </el-tooltip>
                                </template>
                            </template>
                            <template v-else>
                                <el-tooltip class="item" effect="dark" content="点击恢复发货单" placement="top">
                                    <el-popconfirm title="确定恢复该发货单吗？" @confirm="restoreInvoice(scope.row.id)">
                                        <el-button icon="el-icon-refresh" size="mini" type="success" slot="reference"
                                                   circle></el-button>
                                    </el-popconfirm>
                                </el-tooltip>
                            </template>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination background
                               @size-change="handleSizeChange"
                               @current-change="handleCurrentChange"
                               :page-sizes="[50, 100, 200,500]"
                               :page-size="tableSearch.limit"
                               :current-page.sync="tableSearch.pageIndex"
                               layout="total,sizes, prev, pager, next"
                               :total="tableSearch.total">
                </el-pagination>
            </template>
        </el-main>
    </el-container>
    <template>
        <el-dialog :title="dialog.title" :visible.sync="dialog.show" width="95%" center v-loading="dialog.loading"
                   :close-on-click-modal="0" :show-close="0" custom-class="invoice-dialog">
            <el-form label-position="right" label-width="140px" :inline="true" :model="invoiceForm"
                     :rules="invoiceRules" ref="invoiceForm">
                <indent-select @change="indentChange" v-if="dialog.show" :indent-id="invoiceForm.render.indentId"
                               :can-edit="dialog.update"></indent-select>
                <!--  需要录入的信息  -->
                <el-form-item label="生产方式" required prop="render.createType">
                    <!--<el-select v-model="invoiceForm.render.createType" filterable clearable placeholder="生产方式"
                               value-key="id">
                        <el-option v-for="item in createTypeList"
                                   :key="item.code"
                                   :label="item.desc"
                                   :value="item.code + ''">
                        </el-option>
                    </el-select>-->
                    <template
                            v-if="invoiceForm.id != null && invoiceForm.render.createType != 1 && invoiceForm.render.createType != 2">
                        <!-- 修改且不是配额票和手动票的时候不能进行选择 -->
                        <el-input v-model="invoiceForm.render.createType" style="display: none"></el-input>
                        <el-tag style="width: 180px;display: inline-block;">{{invoiceForm.exhibition.createTypeTxt}}
                        </el-tag>
                    </template>
                    <template v-else>
                        <el-select v-model="invoiceForm.render.createType" filterable clearable placeholder="生产方式"
                                   value-key="id">
                            <el-option v-for="item in createTypeList"
                                       :key="item.code"
                                       :label="item.desc"
                                       :value="item.code + ''">
                            </el-option>
                        </el-select>
                    </template>
                </el-form-item>
                <el-form-item label="发货类型" required prop="render.invoiceType">
                    <el-select v-model="invoiceForm.render.invoiceType" filterable clearable placeholder="发货类型"
                               value-key="id" @change="invoiceTypeChange">
                        <el-option v-for="item in invoiceTypeList"
                                   :key="item.code"
                                   :label="item.desc"
                                   :value="item.code + ''">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="发货方量" required prop="render.sendStere">
                    <el-input v-model="invoiceForm.render.sendStere" type="number"></el-input>
                </el-form-item>
                <el-form-item label="生产线"
                              :required="invoiceForm.render.invoiceType == 0 || invoiceForm.render.invoiceType == 1">
                    <el-select v-model="invoiceForm.render.mixId" filterable clearable placeholder="生产线"
                               value-key="id">
                        <el-option v-for="item in mixList"
                                   :key="item.id"
                                   :label="item.name"
                                   :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="生产时间" required prop="render.proTime">
                    <el-date-picker v-model="invoiceForm.render.proTime" class="invoice-time"
                                    value-format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="生产时间">
                    </el-date-picker>
                </el-form-item>
                <br>
                <el-form-item label="调度员" required prop="render.dispatcherName">
                    <el-select v-model="invoiceForm.render.dispatcherName" filterable clearable placeholder="调度员"
                               value-key="id">
                        <el-option v-for="item in dispatcherList"
                                   :key="item.id"
                                   :label="item.name"
                                   :value="item.name"
                                   @click.native="dispatcherChange(item)">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="拌台操作员"
                              :required="invoiceForm.render.invoiceType == 0 || invoiceForm.render.invoiceType == 1">
                    <el-select v-model="invoiceForm.render.mixUserName" filterable clearable placeholder="拌台操作员"
                               value-key="id">
                        <el-option v-for="item in mixUserList"
                                   :key="item.id"
                                   :label="item.name"
                                   :value="item.name"
                                   @click.native="mixUserChange(item)">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="车号" required prop="render.carId">
                    <!--<el-select v-model="invoiceForm.render.carId" filterable clearable placeholder="车号"
                               value-key="id">
                        <el-option v-for="item in carList"
                                   :key="item.id"
                                   :label="item.code"
                                   :value="item.id">
                        </el-option>
                    </el-select>-->
                    <el-select v-model="chooseCar" placeholder="请选择运输车辆" value-key="id" filterable
                               @change="uploadCarChange">
                        <el-option v-for="item in carList"
                                   :key="item.id"
                                   :label="item.code"
                                   :value="item">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="司机">
                    <!--<el-input v-model="invoiceForm.render.driver"></el-input>-->
                    <el-select v-model="chooseDriver" @change="uploadDriver"
                               filterable allow-create
                               default-first-option no-data-text="车辆无打卡数据,请输入司机"
                               placeholder="请选择车辆对应的司机">
                        <el-option v-for="driver in driverList"
                                   :key="driver.id"
                                   :label="driver.name"
                                   :value="driver">
                        </el-option>
                    </el-select>
                </el-form-item>
                <br>
                <el-form-item label="是否累计方量" required>
                    <el-radio-group v-model="invoiceForm.render.isAdd">
                        <el-radio label="0">累计</el-radio>
                        <el-radio label="1">不累计</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="是否计算运输方量" required>
                    <el-radio-group v-model="invoiceForm.render.calcTranStere">
                        <el-radio label="0">计算</el-radio>
                        <el-radio label="1">不计算</el-radio>
                    </el-radio-group>
                </el-form-item>
                <br>
                <el-form-item label="票据类型">
                    <el-select v-model="invoiceForm.render.receiptType" filterable clearable placeholder="票据类型"
                               value-key="id">
                        <el-option v-for="item in receiptTypeList"
                                   :key="item.code"
                                   :label="item.desc"
                                   :value="item.code + ''">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="特殊结算类型">
                    <el-select v-model="invoiceForm.render.specialClearType" filterable clearable placeholder="特殊结算类型"
                               value-key="id">
                        <el-option v-for="item in specialClearTypeList"
                                   :key="item.code"
                                   :label="item.desc"
                                   :value="item.code + ''">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="道路类型">
                    <el-select v-model="invoiceForm.render.roadType" filterable clearable placeholder="道路类型"
                               value-key="id">
                        <el-option v-for="item in roadTypeList"
                                   :key="item.code"
                                   :label="item.desc"
                                   :value="item.code + ''">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="备注" class="invoice-remark">
                    <el-input type="textarea" :rows="2" v-model="invoiceForm.render.remark"></el-input>
                </el-form-item>
                <el-form-item label="运输备注" class="invoice-remark">
                    <el-input type="textarea" :rows="2" v-model="invoiceForm.render.tranRemark"></el-input>
                </el-form-item>
                <el-form-item label="泵送备注" class="invoice-remark">
                    <el-input type="textarea" :rows="2" v-model="invoiceForm.render.pumpRemark"></el-input>
                </el-form-item>

            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="onSubmit('invoiceForm')">确定</el-button>
                <el-button @click="cancel('invoiceForm','dialog')">取 消</el-button>
            </div>
        </el-dialog>
    </template>

    <!-- 发货单消耗 -->
    <el-dialog title="发货单消耗" :visible.sync="invExpendDialog.show" width="70%" center :close-on-click-modal="0"
               v-loading="invExpendDialog.loading" custom-class="handle-expend-dialog">
        <el-descriptions :column="6" size="mini" border class="invoice-data-desc"
                         label-class-name="invoice-data-desc-label">
            <template slot="title">
                工程信息
            </template>
            <el-descriptions-item>
                <template slot="label">
                    <i class="el-icon-office-building"></i>项目名称
                </template>
                {{invExpendDialog.invoice.conName}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <i class="el-icon-s-operation"></i>施工部位
                </template>
                {{invExpendDialog.invoice.site}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <i class="el-icon-s-operation"></i>强度等级
                </template>
                {{invExpendDialog.invoice.strengthName}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <i class="el-icon-s-operation"></i>本车方量
                </template>
                {{invExpendDialog.invoice.sendStere}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <i class="el-icon-truck"></i>累计车次
                </template>
                {{invExpendDialog.invoice.totalCar}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <i class="el-icon-s-operation"></i>累计方量
                </template>
                {{invExpendDialog.invoice.totalStere}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <i class="el-icon-s-order"></i>任务单号
                </template>
                {{invExpendDialog.invoice.indentCode}}
            </el-descriptions-item>
            <el-descriptions-item>
                <template slot="label">
                    <i class="el-icon-s-order"></i>发货单号
                </template>
                {{invExpendDialog.invoice.code}}
            </el-descriptions-item>
        </el-descriptions>
        <el-tabs v-model="invExpendActiveName" type="card" @tab-click="handleClick">
            <template v-for="batchExpend in batchExpends">
                <el-tab-pane :label="'第' + batchExpend.batchNum + '盘'" :name="batchExpend.batchNum">
                    <el-table :data="batchExpend.labExpendList" style="width: 100%" border>
                        <!-- <el-table-column label="盘方量" width="100">
                             {{batchExpend.batchStere}}
                         </el-table-column>-->
                        <el-table-column label="材料名称" prop="nameNorms" width="150"></el-table-column>
                        <el-table-column label="ERP仓位" prop="storageName" width="150"></el-table-column>
                        <el-table-column label="工控仓位" prop="controlStorage" width="150"></el-table-column>
                        <el-table-column label="工控含水量(%)" prop="controlWater" width="150"></el-table-column>
                        <el-table-column label="单方设定用量(KG)" width="150" prop="optimizeQuantity"></el-table-column>
                        <el-table-column label="本盘设定用量(KG)" prop="controlSetQuantity" width="150"></el-table-column>
                        <el-table-column label="本盘实际用量(KG)" prop="controlRealQuantity" width="150"></el-table-column>
                        <el-table-column label="下料时间" prop="useTime" width="180"></el-table-column>
                        <el-table-column label="误差值" prop="conErrorValue" width="100"></el-table-column>
                        <el-table-column label="误差率(%)" prop="conErrorRate" width="100"></el-table-column>
                    </el-table>
                </el-tab-pane>
            </template>
        </el-tabs>
    </el-dialog>
    <!--  整车转料操作  -->
    <whole-tran-dialog v-if="tranDialog.show" :source-invoice="tranSourceInvoice"
                       @closed="closeTranDialog"></whole-tran-dialog>
    <!-- 分车转料操作 -->
    <split-tran-dialog v-if="splitDialog.show" :source-invoice="tranSourceInvoice"
                       @closed="closeTranDialog"></split-tran-dialog>
    <!--  发货单详情  -->
    <invoice-detail-dialog v-if="detailDialog.show" :invoice-id="detailDialog.invoiceId"
                           @closed="detailDialog.show = false"></invoice-detail-dialog>
</div>
</body>
<script type="text/javascript" th:src="@{/static/console/assets/js/jquery-3.2.1.min.js}"></script>
<script type="text/javascript" th:src="@{/static/console/js/pages/base.js}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/static/js/vue.min.js}"></script>
<script type="text/javascript" th:src="@{/static/js/element/index.js}"></script>
<script type="text/javascript" th:src="@{/static/console/datepicker/jquery-datePicker.js}" charset="utf-8"></script>
<script th:src="@{/static/console/js/pages/production/component/indent-select.js?version=202504031025}"></script>
<script th:src="@{/static/console/js/pages/production/component/invoice-select.js?version=202504031026}"></script>
<script th:src="@{/static/console/js/pages/production/component/whole-tran.js?version=202505161106}"></script>
<script th:src="@{/static/console/js/pages/production/component/split-tran.js?version=202505071041}"></script>
<script th:src="@{/static/console/js/pages/production/component/invoice-detail.js?version=202503201743}"></script>
<script type="text/javascript" th:src="@{/static/console/js/pages/inspect/invoice-fz.js?version=202504021632}"
        charset="utf-8"></script>

</html>